home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / ghost / gs403src_amiga.lha / gs4.03 / gdevpipe.c < prev    next >
C/C++ Source or Header  |  1997-03-16  |  3KB  |  92 lines

  1. /* Copyright (C) 1993, 1994 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gdevpipe.c */
  20. /* %pipe% IODevice */
  21. #include "errno_.h"
  22. #include "stdio_.h"
  23. #include "string_.h"
  24. #include "gserror.h"
  25. #include "gstypes.h"
  26. #include "gsmemory.h"        /* for gxiodev.h */
  27. #include "stream.h"
  28. #include "gxiodev.h"
  29.  
  30. /* popen isn't POSIX-standard, so we declare it here. */
  31. /* Because of inconsistent (and sometimes incorrect) header files, */
  32. /* we must omit the argument list. */
  33. extern FILE *popen( /* P2(const char *, const char *) */ );
  34. extern int pclose(P1(FILE *));
  35.  
  36. /* The pipe IODevice */
  37. private iodev_proc_fopen(pipe_fopen);
  38. private iodev_proc_fclose(pipe_fclose);
  39. gx_io_device gs_iodev_pipe = {
  40.     "%pipe%", "FileSystem",
  41.     { iodev_no_init, iodev_no_open_device,
  42.       NULL /*iodev_os_open_file*/, pipe_fopen, pipe_fclose,
  43.       iodev_no_delete_file, iodev_no_rename_file, iodev_no_file_status,
  44.       iodev_no_enumerate_files, NULL, NULL,
  45.       iodev_no_get_params, iodev_no_put_params
  46.     }
  47. };
  48.  
  49. /* The file device procedures */
  50.  
  51. #if !defined(IXEMUL) && defined(AMIGA)
  52. private int
  53. pipe_fopen(gx_io_device *iodev, const char *fname, const char *access,
  54.   FILE **pfile, char *rfname, uint rnamelen)
  55. {    /* The OSF/1 1.3 library doesn't include const in the */
  56.     /* prototype for popen.... */
  57.     errno = 0;
  58.     *pfile = fopen((char *)fname, (char *)access);
  59.     if ( *pfile == NULL )
  60.       return_error(gs_fopen_errno_to_code(errno));
  61.     if ( rfname != NULL )
  62.       strcpy(rfname, fname);
  63.     return 0;
  64. }
  65.  
  66. private int
  67. pipe_fclose(gx_io_device *iodev, FILE *file)
  68. {    fclose(file);
  69.     return 0;
  70. }
  71. #else
  72. private int
  73. pipe_fopen(gx_io_device *iodev, const char *fname, const char *access,
  74.   FILE **pfile, char *rfname, uint rnamelen)
  75. {    /* The OSF/1 1.3 library doesn't include const in the */
  76.     /* prototype for popen.... */
  77.     errno = 0;
  78.     *pfile = popen((char *)fname, (char *)access);
  79.     if ( *pfile == NULL )
  80.       return_error(gs_fopen_errno_to_code(errno));
  81.     if ( rfname != NULL )
  82.       strcpy(rfname, fname);
  83.     return 0;
  84. }
  85.  
  86. private int
  87. pipe_fclose(gx_io_device *iodev, FILE *file)
  88. {    pclose(file);
  89.     return 0;
  90. }
  91. #endif
  92.